<?php
/**
 * PsiFramework
 *
 * Php Simple Framework
 *
 * PHP version 5.3
 *
 * @category  PsiFramework.Plugins.Shop.Classes.Model
 * @package   PsiFramework.Plugins.Shop.Classes.Model
 * @author    Remi San <remi.san@gmail.com>
 * @copyright 2011 Remi San
 * @license   http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @version   SVN: <svn_id>
 * @link      http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins\Shop\Classes\Model\Discount.html
 */

namespace PsiFramework\Plugins\Shop\Classes\Model;

import("Classes.Model.Object");
import("Classes.Util.Parameters.ObjectParameters");

use \PsiFramework\Classes\Model\Object;
use \PsiFramework\Classes\Util\Parameters\ObjectParameters;

/**
 * The Discount Object
 *
 * This is the class for the Discount Object
 *
 * @category PsiFramework.Plugins.Shop.Classes.Model
 * @package  PsiFramework.Plugins.Shop.Classes.Model
 * @author   Remi San <remi.san@gmail.com>
 * @license  http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @link     http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins\Shop\Classes\Model\Discount.html
 */
class Discount extends Object
{

    /**
     * @var int
     */
    protected /*int*/          $_id ;
    
    /**
     * @var string
     */
    protected /*string*/       $_code ;
    
    /**
     * @var Order
     */
    protected /*Order*/        $_order ;
    
    /**
     * @var OrderItem
     */
    protected /*OrderItem*/    $_item ;
    
    /**
     * @var ItemCategory
     */
    protected /*ItemCategory*/ $_category ;
    
    /**
     * @var ItemPackage
     */
    protected /*ItemPackage*/  $_package ;
    
    /**
     * @var int
     */
    protected /*int*/          $_minQuantity ;
    
    /**
     * @var int
     */
    protected /*int*/          $_maxQuantity ;
    
    /**
     * @var float
     */
    protected /*float*/        $_value ;
    
    /**
     * @var bool
     */
    protected /*bool*/         $_percentage ;
    
    
    /**
     * Constructor
     * 
     * @param int          $id          The id
     * @param string       $code        The code
     * @param Order        $order       The order
     * @param OrderItem    $item        The item
     * @param ItemCategory $category    The category
     * @param ItemPackage  $package     The package
     * @param int          $minQuantity The min quantity
     * @param int          $maxQuantity The max quantity
     * @param float        $value       The value
     * @param bool         $percentage  Is the value a percentage ?
     * 
     * @return ItemCategory
     */
    public function __construct(
        /*int*/          $id=null,
        /*string*/       $code=null,
        /*Order*/        $order=null,
        /*OrderItem*/    $item=null,
        /*ItemCategory*/ $category=null,
        /*ItemPackage*/  $package=null,
        /*int*/          $minQuantity=null,
        /*int*/          $maxQuantity=null,
        /*float*/        $value=null,
        /*bool*/         $percentage=null
    )
    {
        $this->_id = $id ;
        $this->_code = $code ;
        $this->_order = $order ;
        $this->_item = $item ;
        $this->_category = $category ;
        $this->_package = $package ;
        $this->_minQuantity = $minQuantity ;
        $this->_maxQuantity = $maxQuantity ;
        $this->_value = $value ;
        $this->_percentage = $percentage ;
    }

    /**
     * Getter for the id / primary key
     *
     * @see Object::getId()
     *
     * @return int
     */
    public function getId()
    {
        return $this->_id ;
    }

    /**
     * Setter for the id
     *
     * @param int $id The id
     *
     * @return void
     */
    public function setId(/*int*/ $id)
    {
        $this->_id = $id ;
    }
    
    /**
     * Getter for the code
     *
     * @return string
     */
    public function getCode()
    {
    	return $this->_code ;
    }
    
    /**
     * Setter for the code
     *
     * @param string $code The code
     *
     * @return void
     */
    public function setCode(/*string*/ $code)
    {
    	$this->_code = $code ;
    }
    
    
    /**
     * Getter for the order
     *
     * @return Order
     */
    public function getOrder()
    {
    	return $this->_order ;
    }
    
    /**
     * Setter for the order
     *
     * @param Order $order The order
     *
     * @return void
     */
    public function setOrder(/*Order*/ $order)
    {
    	$this->_order = $order ;
    }
    
    /**
     * Getter for the item
     *
     * @return OrderItem
     */
    public function getItem()
    {
    	return $this->_item ;
    }
    
    /**
     * Setter for the item
     *
     * @param OrderItem $item The item
     *
     * @return void
     */
    public function setItem(/*OrderItem*/ $item)
    {
    	$this->_item = $item ;
    }    
    
    /**
     * Getter for the category
     *
     * @return ItemCategory
     */
    public function getCategory()
    {
    	return $this->_category ;
    }
    
    /**
     * Setter for the category
     *
     * @param ItemCategory $category The category
     *
     * @return void
     */
    public function setCategory(/*ItemCategory*/ $category)
    {
    	$this->_category = $category ;
    }
    
    /**
     * Getter for the package
     *
     * @return ItemPackage
     */
    public function getPackage()
    {
    	return $this->_package ;
    }
    
    /**
     * Setter for the package
     *
     * @param ItemPackage $package The package
     *
     * @return void
     */
    public function setPackage(/*ItemPackage*/ $package)
    {
    	$this->_package = $package ;
    }
    
    
    /**
     * Getter for the min quantity
     *
     * @return int
     */
    public function getMinQuantity()
    {
    	return $this->_minQuantity ;
    }
    
    /**
     * Setter for the min quantity
     *
     * @param int $minQuantity The min quantity
     *
     * @return void
     */
    public function setMinQuantity(/*int*/ $minQuantity)
    {
    	$this->_minQuantity = $minQuantity ;
    }
    
    /**
     * Getter for the max quantity
     *
     * @return int
     */
    public function getMaxQuantity()
    {
    	return $this->_maxQuantity ;
    }
    
    /**
     * Setter for the max quantity
     *
     * @param int $maxQuantity The max quantity
     *
     * @return void
     */
    public function setMaxQuantity(/*int*/ $maxQuantity)
    {
    	$this->_maxQuantity = $maxQuantity ;
    }
    
    /**
     * Getter for the value
     *
     * @return float
     */
    public function getValue()
    {
    	return $this->_value ;
    }
    
    /**
     * Setter for the value
     *
     * @param float $value The value
     *
     * @return void
     */
    public function setValue(/*float*/ $value)
    {
    	$this->_value = $value ;
    }
    
    /**
     * Is the value a percentage ?
     *
     * @return bool
     */
    public function isPercentage()
    {
    	return $this->_percentage ;
    }
    
    /**
     * Setter for the percentage
     *
     * @param bool $percentage is it a percentage ?
     *
     * @return void
     */
    public function setPercentage(/*bool*/ $percentage)
    {
    	$this->_percentage = $percentage ;
    }
    
    /**
     * Function that returns the value of the discount
     * as a formatted string
     * 
     * @param string $currency The default currency symbol
     * 
     * @return string
     */
    public function getStringDiscountValue(/*string*/ $currency='€')
    {
        $string = '';
        
        if ($this->isPercentage()) {
            $string = $this->getValue() . '%';
        } else {
            $string = number_format($this->getValue(), 2, '.', ' ') . $currency;
        }
        
        return $string;
    }
    
    /**
     * Shows the Discount as a string
     *
     * @see Object::toString()
     *
     * @return string
     */
    public function toString()
    {
        
    }

}
